package com.siwei.mes.controller.laboratory;

import com.siwei.mes.common.annotation.AnonymousAccess;
import com.siwei.mes.common.result.ApiResult;
import com.siwei.mes.common.result.Json;
import com.siwei.mes.mapper.laboratory.TestLaboratoryMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 测试实验室接口
 *
 * @Description: 测试实验室接口
 * @Version: 1.0
 * @author: mlchen
 * @date: 2024/6/10 20:47
 */
@RestController
@RequestMapping("testLaboratory")
public class TestLaboratoryController {
    @Resource
    private TestLaboratoryMapper testLaboratoryMapper;

    @AnonymousAccess
    @GetMapping("insetImportList")
    public Json insetImportList() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String importDate = sdf.format(new Date());
        String kindId = "11";
        String itemId = "1101";
        String sampleId = "110114";
        String gradeId = "110114203";
        String importId = "2024001077-1";
        String specId = "0";
        String prodinQuan = "56.22";
        testLaboratoryMapper.insertImportList(importDate, kindId, itemId, sampleId, gradeId, importId, specId, prodinQuan);
        return Json.succ();
    }


    @AnonymousAccess
    @GetMapping("insertSmallDataTime")
    public Json insertSmallDataTime() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String smallDataTime = sdf.format(new Date());

        String sampleNo = "linzi";
        String sampleName = "linzi";
        String s2 = smallDataTime;
        String s7 = smallDataTime;
        String s9 = smallDataTime;
        testLaboratoryMapper.insertSmallDataTime(sampleNo, sampleName, s2, s7, s9);
        return Json.succ();
    }

    @AnonymousAccess
    @GetMapping("test")
    public Json test() {
        List<Map<String, Object>> mapList = testLaboratoryMapper.testSelect();
        return Json.succ().data(ApiResult.addList(mapList));
    }


    @AnonymousAccess
    @GetMapping("testUpdate")
    public Json testUpdate() {
        testLaboratoryMapper.updateTest();
        return Json.succ();
    }

}
